// 引入mongoose
const mongoose = require("mongoose");
const Schema = mongoose.Schema;

// 连接MongoDB数据库,如果端口号是默认的（27017），可以不用写
mongoose.connect('mongodb://localhost:27017/ims')

// 创建账号的Schema
const accountSchema = new Schema({
    account: String,
    password: String,
    name: String,
    nickname: String,
    sex: {
        type: String,
        defalut: 'male',
    },
    birthday: String,
    power: String,
    remark: String,
    creatTime: {
        type: String,
        defalut: new Date(),
    }
})

// 创建页面的Schema
const pagesSchema = new Schema({
    path: String,
    name: String,
    component: String,
    meta: {
        isMenu: Boolean,
        isRoute: Boolean,
        hasSubMenu: Boolean,
        title: String,
        icon: String
    },
    children: Array
})

const Models = {
    accountInfo: mongoose.model('account', accountSchema),
    pagesInfo: mongoose.model('pages', pagesSchema)
}

export default Models